package sdk.webview.fmc.com.fmcsdk.presenter;

import sdk.webview.fmc.com.fmcsdk.base.BasePresenter;
import sdk.webview.fmc.com.fmcsdk.base.CommonApi;
import sdk.webview.fmc.com.fmcsdk.bean.AgreementBean;
import sdk.webview.fmc.com.fmcsdk.interfaces.AgreementView;
import sdk.webview.fmc.com.fmcsdk.util.Url;
import sdk.webview.fmc.com.fmcsdk.util.retrofit2.observer.ResponseTransformer;
import sdk.webview.fmc.com.fmcsdk.util.retrofit2.subscriber.ResponseSubscriber;

/**
 * Created by ydm on 2019/10/17.
 */

public class AgreementPresenter extends BasePresenter<AgreementView> {

    public void getAgreement() {

        view.showLoading();
        getApi(CommonApi.class).getAgreement(getDefaultAddress()+ Url.AGREEMENT)
                .compose(new ResponseTransformer<>(this.<AgreementBean>bindToLifeCycle()))
                .subscribe(new ResponseSubscriber<AgreementBean>(view) {
                    @Override
                    public void success(AgreementBean baseData) {
                    view.agreementContent(baseData.getRecords().get(0).getValue());
                    }
                    @Override
                    public void onRequestAgain() {
                    }
                });
    }
}
